package com.huanri.patterns.visitor;

import java.util.Collection;
import java.util.Iterator;

/**
 * @author Nemo
 * @date 2012-8-21 at MyCode
 */
public class ConcreteVisitor implements Visitor {

	public void visitCollection(Collection collection) {
		Iterator iterator = collection.iterator();
        while (iterator.hasNext()) {
            Object o = iterator.next();
            if (o instanceof Visitable) {
                ((Visitable)o).accept(this);
            }
        }
	}

	public void visitString(StringElement stringE) {
		System.out.println(stringE.getStr());
	}

	public void visitFloat(FloatElement floatE) {
		System.out.println(floatE.getFe());
	}
}
